<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use App\Imports\ResumeImport;
use App\Models\Resume;
use App\Jobs\ResumeJob;

class FxPost extends Action
{
    public $name = '分析简历';

    protected $selector = '.fx-post';

    public function handle()
    {
        // 下面的代码获取到上传的文件，然后使用`maatwebsite/excel`等包来处理上传你的文件，保存到数据库
        
      

       $res = Resume::query()->where("id",">",200)->get();
      
       foreach($res as $v){
            dispatch(new ResumeJob($v))->onQueue('default');

       }
      
       // Excel::import(new ResumeImport(), $path);

        return $this->response()->success('正在分析中，请耐心等待！')->refresh();
    }

    
    
    public function dialog()
    {
        $this->confirm('确定分析数据吗?');
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default fx-post"><i class="fa fa-upload"></i>分析简历</a>
HTML;
    }
}